package nc.ui.pp.supplierprice.config.handler;

import nc.pub.pp.cons.DefFieldCons;
import nc.ui.pp.supplierprice.util.TaxRateCalcUtil;
import nc.ui.pubapp.uif2app.event.IAppEventHandler;
import nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent;
import nc.vo.pp.supplierprice.entity.SupplierPriceVO;

public class TaxcodeBodyAfterEditHandler implements IAppEventHandler<CardBodyAfterEditEvent>{

	@Override
	public void handleAppEvent(CardBodyAfterEditEvent event) {
		if(event.getKey().equals(DefFieldCons.PP_BODY_TAXCODEID)) {
			Object value = null;
			if(event.getValue() != null) {
				SupplierPriceVO itemvo = (SupplierPriceVO) event.getBillCardPanel().getBillModel().getBodyValueRowVO(event.getRow(), SupplierPriceVO.class.getName());
				
				TaxRateCalcUtil.calcVATInfoByTaxCode(itemvo);
				
				value = itemvo.getNtaxrate();
			}
			
			event.getBillCardPanel().getBillModel().setValueAt( value, event.getRow(), "ntaxrate");
		}
	}
}
